.PHONY: all sync clean list help

define NOP
	@nop=
endef

PROJECT_DIR = project
REPO_DIR = .repo
REPO_URL = https://gitee.com/DAI_David/manifests.git
REPO_BARCH = master

ifdef OS
REPO_TOOL = tools/git-repo.exe
RM_TOOL = RM
else
REPO_TOOL = tools/git-repo
RM_TOOL = rm
endif

all:help

sync:
ifneq ($(wildcard ${PROJECT_DIR}),)
	@${RM_TOOL} -rf ${PROJECT_DIR}
endif
	$(info Repo sync project...)
	@${REPO_TOOL} sync

clean:
ifneq ($(wildcard ${PROJECT_DIR}),)
	@${RM_TOOL} -rf ${PROJECT_DIR}
endif
ifneq ($(wildcard ${REPO_DIR}),)
	@${RM_TOOL} -rf ${REPO_DIR}
endif
	$(info Clean repo project)

list:
	$(info Support project list: $(subst .xml,,$(subst configs/,,$(wildcard configs/*.xml))))
	${NOP}

%_config:configs/%_config.xml
	$(info Repo init $< project...)
	@${REPO_TOOL} init -u ${REPO_URL} -b ${REPO_BARCH} -m $<

help:
	$(info Usage: make [target])
	$(info Targets:)
	$(info list         List all repo project configuration)
	$(info XXX_config   Init the project named XXX_config, use "make list" to view support list.)
	$(info sync         Sync repo project.)
	$(info clean        Delete repo project.)
	${NOP}